import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { BeforeInsert, Column, PrimaryColumn } from 'typeorm';

import { StaticSnowFlake } from '../utils/flake-id';
import { DateBaseEntity } from './date.base.entity';

export class BaseEntity extends DateBaseEntity {
  @BeforeInsert()
  beforeInsert() {
    this.id = StaticSnowFlake.next();
  }

  @PrimaryColumn({
    // generated: true,
    comment: '主键ID',
    type: 'varchar',
    length: 32,
    unique: true,
  })
  id: string;

  @ApiProperty({ description: '备注' })
  @Column({ comment: '备注', nullable: true })
  remark?: string;
}
